{% set namespace = "acs_serverless" %}
{% set dff_api_title = "AlibabaCloud-SAE Application Collection" %}
{% set dff_api_crontab = "* * * * *" %}

{% extends "base_template" %}
{% block import %}
{{ super() }}
import integration_alibabacloud_sae_app__main as obj_app_main
import integration_alibabacloud_sae_app_instance__main as obj_app_instance_main
import integration_alibabacloud_monitor__main as monitor_main
{% endblock %}

{% block account %}
{{ super() }}
{% endblock %}

{% block collect_configs %}
collector_configs = {
    'regions': {{ repr(collector.regions) }}
}

monitor_configs = {
    'targets': [
        {
            'namespace': {{ repr(namespace) }},
            {% if collector.metrics %}
            'metrics'  : {{ repr(collector.metrics) }}
            {% else %}
            'metrics'  : []
            {% endif %}
        }
    ]
}
{% endblock %}

{% block filters%}
{% endblock %}

{% block run %}
@DFF.API('{{ dff_api_title }}', timeout=300, fixed_crontab='{{ dff_api_crontab }}')
def run():
    collectors = [
        obj_app_main.DataCollector(account, collector_configs),
        obj_app_instance_main.DataCollector(account, collector_configs),
        monitor_main.DataCollector(account, monitor_configs),
    ]
    Runner(collectors).run()
{% endblock %}
